<template>
	<div class="body">
		<view @click="pageTo">
			<uni-fab></uni-fab>
		</view>
		<div class="container">	
			<div class="tab-container">
				<div class="tab" @click="change('1')" :class="selectedNum == '1' ? 'active' : ''">已通过</div>
				<div class="tab" @click="change('-1')" :class="selectedNum == '-1' ? 'active' : ''">已拒绝</div>
				<div class="tab" @click="change('0')" :class="selectedNum == '0' ? 'active' : ''">待审批</div>
			</div>
			<div class="leave-list">
				<scroll-view v-if="list.length">
					<div class="leave-item" data-status="pending" v-for="(item,index) in list" @click="info(item)">
						<div class="leave-header">
							<span class="student-name">{{item.studentName}}的请假申请</span>
							<view v-if="item.status==0" class="status" style="color:skyblue;background-color:#dbf6ff;">待审批</view>
							<view v-else-if="item.status==1" class="status" style="color:#618d59;background-color:#dbffdb;">已通过</view>
							<view v-else-if="item.status==-1" class="status" style="color:firebrick;background-color:#ffd5d6;">已拒绝</view>
						</div>
						<div class="leave-info">
							<div class="leave-reason">
								请假时间:
							</div>
							<div class="leave-reason">
								{{item.startTime}} ~ {{item.endTime}}
							</div>
							<div class="leave-time">
								请假事由:
							</div>
							<div class="leave-time">
								{{item.leaveReason}}
							</div>
						</div>
					</div>
				</scroll-view>
				<view v-else class="nomessage">
					<view style="width: 200px;height:200px;">
						<image style="width: 200px;height:200px;" :src="'/static/nomessage.png'" mode="aspectFill"></image>
					</view>
					<view style="font-weight: 800;">这里没有任何消息</view>
				</view>
			</div>
		</div>
	</div>
</template>

<script>
	import uniFab from '@/uni_modules/uni-fab/components/uni-fab/uni-fab.vue'
	import { getLeaveListApi } from '@/common/api/timeleave'
	export default {
		data() {
			return {
				selectedNum: '0',
				list: [],
				id: ''
			}
		},
		computed: {
		},
		components: {
			uniFab
		},
		mounted() {
			// // 从本地存储获取字符串
			// const userString = uni.getStorageSync('info');
			
			// // 将字符串解析为对象
			// const user = userString ? JSON.parse(userString) : null;
			// this.id = user.userId
			
			this.change('0')
		},
		methods: { 
			pageTo() {
				uni.navigateTo({
					url: '/pages/excused/request'
				})
			},
			change(num) {
				this.selectedNum = num
				this.list = []
				getLeaveListApi({
					status: num
				}).then((listRes) => {
					this.list = listRes.data.rows
				})
			},
			info(item){
				uni.navigateTo({
					url: `/pages/excused/info?id=` + item.leaveId
				})
			}
		}
	}
</script>


<style>
	.nomessage {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		/* justify-content: center; */
		align-items: center;
		padding-top: 180px;
	}
	.aaa{
		background-color: #618d59;
	}
	* {
		margin: 0;
		padding: 0;
		box-sizing: border-box;
	}
	
	body {
		font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
		background: linear-gradient(135deg, #f7e8c9 0%, #85cffd 100%);
		min-height: 100vh;
		padding: 15px;
	}
	
	.container {
		max-width: 800px;
		margin: 0 auto;
		background-color: rgba(255, 255, 255, 0.95);
		border-radius: 16px;
		box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
		padding: 20px;
		height: calc(100vh - 30px);
		display: flex;
		flex-direction: column;
	}
	
	.header {
		text-align: center;
		padding: 10px;
		background: linear-gradient(45deg, #8BB8E8, #9B8BE8);
		border-radius: 12px;
		margin-bottom: 15px;
		flex-shrink: 0;
	}
	
	.header h1 {
		color: white;
		font-size: 1.8rem;
		text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
	}
	
	.tab-container {
		display: flex;
		justify-content: space-around;
		margin-bottom: 15px;
		background: rgba(139, 184, 232, 0.1);
		padding: 10px;
		border-radius: 12px;
		flex-shrink: 0;
	}
	
	.tab {
		padding: 10px 20px;
		border-radius: 8px;
		cursor: pointer;
		transition: all 0.3s;
		font-size: 1rem;
		color: #636E72;
	}
	
	.tab.active {
		background: linear-gradient(45deg, #8BB8E8, #9B8BE8);
		color: white;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	}
	
	.leave-list {
		flex: 1;
		overflow-y: auto;
		padding-right: 5px;
	}
	
	.leave-list::-webkit-scrollbar {
		width: 6px;
	}
	
	.leave-list::-webkit-scrollbar-track {
		background: #f1f1f1;
		border-radius: 3px;
	}
	
	.leave-list::-webkit-scrollbar-thumb {
		background: #8BB8E8;
		border-radius: 3px;
	}
	
	.leave-list::-webkit-scrollbar-thumb:hover {
		background: #9B8BE8;
	}
	
	.leave-item {
		background: white;
		border-radius: 12px;
		padding: 15px;
		margin-bottom: 15px;
		border-left: 5px solid #8BB8E8;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
	}
	
	.leave-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 10px;
	}
	
	.student-name {
		font-size: 1.2rem;
		color: #2D3436;
		font-weight: 500;
	}
	
	.status {
		padding: 5px 12px;
		border-radius: 20px;
		font-size: 0.9rem;
	}
	
	.leave-info {
		color: #636E72;
		line-height: 1.6;
	}
	
	.leave-time {
		color: #8BB8E8;
		font-size: 0.9rem;
		margin: 5px 0;
	}
	
	.leave-reason {
		color: #636E72;
		margin-top: 8px;
		font-size: 0.95rem;
	}
	
	@media screen and (max-width: 768px) {
		body {
			padding: 10px;
		}
	
		.container {
			height: calc(100vh - 20px);
			padding: 15px;
		}
	
		.header h1 {
			font-size: 1.5rem;
		}
	
		.tab-container {
			padding: 8px;
		}
	
		.tab {
			padding: 8px 12px;
			font-size: 0.9rem;
		}
	
		.leave-header {
			flex-direction: row;
			flex-wrap: wrap;
			gap: 8px;
		}
	
		.student-name {
			font-size: 1.1rem;
		}
	
		.status {
			padding: 4px 10px;
			font-size: 0.8rem;
		}
	
		.leave-time {
			font-size: 0.85rem;
		}
	
		.leave-reason {
			font-size: 0.9rem;
		}
	
		.leave-item {
			padding: 12px;
			margin-bottom: 10px;
		}
	}
	
	@media screen and (max-width: 320px) {
		.container {
			padding: 10px;
		}
	
		.header h1 {
			font-size: 1.3rem;
		}
	
		.tab {
			padding: 6px 8px;
			font-size: 0.8rem;
		}
	}
	/* .tab {
		color: #fff;
		background-color: #8ac1d5;
		width: 50px;
		height: 50px;
		margin: 5px;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 25px;
		margin-left: 350px;
	}

	.titleTab {
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		border-bottom: 1px solid #bfbfbf;
		color: #bfbfbf;
		padding-bottom: 5px;
	}

	.checked {
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		padding-bottom: 10px;
		color: #000;
	}

	.checked::after {
		content: '';
		position: absolute;
		bottom: 0;
		width: 20px;
		height: 2px;
		background-color: #000;
		left: 50%;
		transform: translateX(-50%);
	}

	.listItem {
		margin: 10px;
		padding-bottom: 10px;
		border-bottom: 1px solid #d9d9d9;
	}

	.avart {
		background-color: #84c3fa;
		color: #fff;
		border-radius: 15px;
		width: 30px;
		height: 30px;
		font-size: 14px;
		margin-right: 10px;
	} */
</style>